/*******************************************/
/*        (c) Pavel Bacovsky, Ph.D.        */
/*     			Bates College		       */
/*  	   Department of Politics		   */
/*           Lewiston, ME 04240            */
/*           pbacovsky@bates.edu           */  
/*             www.bacovsky.phd            */
/*******************************************/ 

clear

/********************************************/
/*        DATA RENAMING & LABELING          */
/********************************************/

import excel "Bacovsky-LevelUpData_JEPS_Import.xlsx", sheet("Sheet0") firstrow case(lower)

rename durationinseconds duration
rename q_recaptchascore captcha
rename q_relevantidduplicate dupid
rename q_relevantidduplicatescore dupscore
rename q_relevantidfraudscore fraudscore
rename d7_7_text d7_text
rename fl_8_do_control control
rename fl_8_do_treatment treatment

la var captcha "Recaptcha Score"
la var dupid "Response Duplicate ID"
la var dupscore "Response Duplicate Score"
la var fraudscore "Response Fraud Score"

la var q1 "Consent"

* Pre-test value of DV - Interest in US foreign trade policy *
la var pt1 "Interest in US foreign trade policy, pre-test" 
la de interest 1 "1 = Strongly disinterested" 10 "10 = Strongly interested"
la val pt1 interest

* Gamer Self-Identification *
la var pt2 "Importance of being a gamer"
la de importance 1 "Not important at all" 2 "Not very important" 3 "Very important" 4 "Extremely important"
la val pt2 importance
gen pt2_log=log(pt2)
la var pt2_log "Importance of being a gamer, logged"
order pt2_log, after (pt2)

la var pt3 "How well gamer describes"
la de describes 1 "Not at all" 2 "Not very well" 3 "Very well" 4 "Extremely well"
la val pt3 describes
gen pt3_log=log(pt3)
la var pt3_log "How well gamer describes, logged"
order pt3_log, after (pt3)

la var pt4 "Gamers = we"
la de usthem 1 "Never" 2 "Rarely" 3 "Some of the time" 4 "Most of the time" 5 "All of the time"
la val pt4 usthem
gen pt4_1=pt4
la var pt4_1 "Gamers = we, version 2"
la de usthem2 1 "Never" 2 "Rarely" 3 "Some of the time" 4 "Most/All of the time"
la val pt4_1 usthem2
replace pt4_1=4 if pt4==5
order pt4_1, after (pt4)
gen pt4_log=log(pt4)
la var pt4_log "Gamers = we, logged"
order pt4_log, after (pt4_1)

la var pt5 "Gamer self-image"
la de selfimg 1 "Not at all" 2 "Very little" 3 "Somewhat" 4 "A great deal"
la val pt5 selfimg
gen pt5_log=log(pt5)
la var pt5_log "Gamer self-image, logged"
order pt5_log, after (pt5)
 
* Preferred Gaming Platform * 
la var pt6_1 "Platform = Desktop" 
la var pt6_2 "Platform = Laptop"
la var pt6_3 "Platform = Phone"
la var pt6_4 "Platform = Handheld" 
la var pt6_5 "Platform = Console" 
la var pt6_6 "Platfrom = No Platform"

* Preferred Gaming Genre * 
la var pt7_1 "Genre = Action Adventure" 
la var pt7_2 "Genre = Action RPG"
la var pt7_3 "Genre = Atmospheric Exploration" 
la var pt7_4 "Genre = Battle Royale" 
la var pt7_5 "Genre = Casual Puzzle" 
la var pt7_6 "Genre = City Building" 
la var pt7_7 "Genre = Interactive Drama" 
la var pt7_8 "Genre = Japanese RPG" 
la var pt7_9 "Genre = Family/Farm Sim" 
la var pt7_10 "Genre = FPS" 
la var pt7_11 "Genre = Match 3"
la var pt7_12 "Genre = MMO" 
la var pt7_13 "Genre = MOBA" 
la var pt7_14 "Genre = Open World Adventure" 
la var pt7_15 "Genre = Platformer" 
la var pt7_16 "Genre = Racing" 
la var pt7_17 "Genre = Sandbox" 
la var pt7_18 "Genre = Sports" 
la var pt7_19 "Genre = Rougelike" 
la var pt7_20 "Genre = Strategy, Real-Time" 
la var pt7_21 "Genre = Strategy, Turn-Based"
la var pt7_22 "Genre = Western RPG"
la var pt7_23 "Genre = No Genre"
order pt7_10, after(pt7_9)

* Money Spent on Gaming * 
la var pt8 "Money spent on games, monthly"
 
* Time Spent Gaming *
la var pt9 "Time spent gaming, daily"
la de gametime 1 "No time" 2 "Up to 30 minutes" 3 "30 minutes - 1 hour" 4 "1-3 hours" 5 "3-6 hours" 6 "More than 6 hours"
la val pt9 gametime
gen pt9_1=.
replace pt9_1=1 if pt9==1
replace pt9_1=2 if pt9==2
replace pt9_1=2 if pt9==3
replace pt9_1=3 if pt9==4
replace pt9_1=4 if pt9==5
replace pt9_1=5 if pt9==6
la var pt9_1 "Time spent gaming, daily v2"
la de gametime2 1 "No time" 2 "Up to 1 hour" 3 "1-3 hours" 4 "3-6 hours" 5 "More than 6 hours"
la val pt9_1 gametime2
order pt9_1, after (pt9)
gen pt9_log=log(pt9)
la var pt9_log "Time spent gaming, logged"
order pt9_log, after (pt9_1)

* Online/Offline Gaming *
la var pt10 "Gaming online-offline"
la de olgame 1 "1 = Only offline" 10 "10 = Only online" 
la val pt10 olgame

* Gamer Identity Index * - Data from the alpha command are used to create table A2.2.
alpha pt2 pt3 pt4_1 pt5, detail item
alpha pt2 pt3 pt5, detail item
factor pt2 pt3 pt5, pcf
rotate, promax
gen gid = (pt2 + pt3 + pt5)/3
tab gid
la var gid "Gamer Identity Index"

* Gamer Yes/No *
tab gid
sum gid, detail
tab pt9
sum pt9, detail
	
* Anywone with GID greater than 2.5 is considered a gamer.
* Anyone who plays at least 1 hour a day is considered gamer.

gen gamer_sid = 1 if gid >= 2.5
replace gamer_sid = 0 if gamer_sid == .
la de gamla 0 "Not a Gamer" 1 "Gamer"
la val gamer_sid gamla
la var gamer_sid "Gamer Y/N, self-ID"

gen gamer_tm = 1 if pt9>3
replace gamer_tm = 0 if gamer_tm == .
la val gamer_tm gamla
la var gamer_tm "Gamer Y/N, time spent" 

* Control vs. Treatment *
la var control "Respondent received control manipulation"
destring control, replace
replace control=0 if control==.
la var treatment "Respondent received treatment manipulation"
destring treatment, replace
replace treatment=0 if treatment==.

order control, before(b1)
order treatment, after(control)

* Bot Check *
la var b1 "Bot Check"
replace b1="13" if b1=="thirteen"
replace b1="13" if b1=="1e"
destring b1, replace

* Manipulations Checks *
la var mc1 "Goods Manipulation Check" 
la de goods 1 "Steel and copper" 2 "Videogames" 3 "Pharmaceuticals" 4 "No specifics"
la val mc1 goods

la var mc2 "Countries Manipulation Check"
la de countries 1 "US and EU" 2 "US and Japan" 3 "US and China" 4 "No specifics"
la val mc2 countries

la var mc3 "Prices Manipulation Check"
la de prices 1 "Prices go up" 3 "Prices stay same" 4 "Prices go down"
la val mc3 prices

** Dependent Variables **
 
la var dv11_1 "General interest in US foreign trade policy" 
la var dv11_2 "Interest in US foreign trade policy discussed in prompt"
la val dv11_1 interest
la val dv11_2 interest

*Pre-test/post-test difference*
gen genint_diff=dv11_1-pt1
la var genint_diff "Difference in General Interest in U.S. foreign trade between pre- and post-test"
 
la var dv12 "Agreement with policy in article"
la de agrees 1 "1 = Strongly disagree" 10 "10 = Strongly agree" 
la val dv12 agrees

la var dv13 "Support for policy in article"
la de supports 1 "1 = Strongly Oppose" 10 "10 = Strongly Support" 
la val dv13 supports
 
la var dv14_1 "Likely to forward article to friend" 
la var dv14_2 "Likely to forward article to family" 
la var dv14_3 "Likely to write a supporting social media post" 
la var dv14_4 "Attention check"
la var dv14_5 "Likely to write an opposing social media post" 
la var dv14_6 "Likely to write a supporting op-ed" 
la var dv14_7 "Likely to write an opposing op-ed"

la de likely 1 "1 = Extremely Unlikely" 10 "10 = Extremely Likely"
la val dv14_1 likely 
la val dv14_2 likely
la val dv14_3 likely
la val dv14_4 likely
la val dv14_5 likely
la val dv14_6 likely 
la val dv14_7 likely

la var dv21_1 "Candidate vote" 
la var dv21_2 "Candidate donate" 
la var dv21_3 "Candidate volunteer"

la de candidate 1 "Definitely Simon Bloggs" 2 "Likely Simon Bloggs" 3 "Likely David Smith" 4 "Definitely David Smith"
la val dv21_1 candidate
la val dv21_2 candidate
la val dv21_3 candidate

gen blog_v = 0
replace blog_v = 1 if dv21_1==1 | dv21_1==2
la var blog_v "Votes for Blogg"
gen blog_d = 0
replace blog_d = 1 if dv21_2==1 | dv21_2==2
la var blog_d "Donates to Blogg"
gen blog_h = 0
replace blog_h = 1 if dv21_3==1 | dv21_3==2
la var blog_h "Volunteers for Blogg"
 
** Demographic Variables **

* Age *
la var d1 "Age"
sum d1, detail
gen d1_cat=.
la de agecat 1 "0-14" 2 "15-24" 3 "25-54" 4 "55-64" 5 "65 and older"
replace d1_cat=1 if d1 < 15
replace d1_cat=2 if d1 >= 15 & d1 < 25
replace d1_cat=3 if d1 >= 25 & d1 < 55
replace d1_cat=4 if d1 >= 55 & d1 < 64
replace d1_cat=5 if d1 >= 65
la var d1_cat "Age brackets"
la val d1_cat agecat
order d1_cat, after(d1)
tab d1_cat

* State of Residence*
la var d2 "State of residence" 
la de state 1 "Alabama" 2 "Alaska" 3 "Arizona" 4 "Arkansas" 5 "California" 6 "Colorado" 7 "Connecticut" 8 "Delaware" 9 "District of Colombia" 10 "Florida" 11 "Georgia" 12 "Hawaii" 13 "Idaho" 14 "Illinois" 15 "Indiana" 16 "Iowa" 17 "Kansas" 18 "Kentucky" 19 "Louisiana" 20 "Maine" 21 "Maryland" 22 "Massachusetts" 23 "Michigan" 24 "Minnesota" 25 "Mississippi" 26 "Missouri" 27 "Montana" 28 "Nebraska" 29 "Nevada" 30 "New Hampshire" 31 "New Jersey" 32 "New Mexico" 33 "New York" 34 "North Carolina" 35 "North Dakota" 36 "Ohio" 37 "Oklahoma" 38 "Oregon" 39 "Pennsylvania" 40 "Puerto Rico" 41 "Rhode Island" 42 "South Carolina" 43 "South Dakota" 44 "Tennessee" 45 "Texas" 46 "Utah" 47 "Vermont" 48 "Virginia" 49 "Washington" 50 "West Virginia" 51 "Wisconsin" 52 "Wyoming" 53 "Not US"
la val d2 state

* City Size *
la var d3 "City size"
la de city 1 "Open country" 2 "Small town or village" 3 "Town, 2,500 - 9,999" 4 "City, 10,000 - 49,999" 5 "City, 50,000 - 250,000" 6 "City greater than 250,000"
la val d3 city 
 
la var d4 "Employment status"
la de jobs 1 "Employed for wages" 2 "Self-employed" 3 "Out of work and looking for work" 4 "Out of work but not currently looking for work" 5 "A homemaker" 6 "A student" 7 "Military" 8 "Retired" 9 "Unable to work"
la val d4 jobs
 
la var d5 "Education attainment"
la de educ 1 "Some high school or lower" 2 "High school graduate, diploma, or the equivalent (e.g., GED)" 3 "Some college credit, no degree" 4 "Trade/technical/vocational training" 5 "Associate degree" 6 "Bachelor's degree" 7 "Graduate or Professional Degree or higher" 
la val d5 educ

la var d6 "Gender"
la de sex 1 "Male" 2 "Female" 3 "Neither"
la val d6 sex
 
la var d7 "Race, choice"
la de race 1 "White" 2 "Hispanic or Latino" 3 "Black or African American" 4 "Native American, American Indian, or Alaskan Native" 5 "Asian" 6 "Native Hawaiian or Pacific Islander" 7 "Other"
la val d7 race
 
la var d7_text "Race, write-in" 
la var d8 "Annual household income" 

la var d9 "Party ID"
la de pid 1 "Strong Democrat" 2 "Moderate Democrat" 3 "Independent, leaning Democrat" 4 "Independent" 5 "Independent, leaning Republican" 6 "Moderate Republican" 7 "Strong Republican"
la val d9 pid

la var d10 "Liberal-Conservative"
la de laco 1 "1 = Extremely Liberal" 10 "10 = Extremely Conservative"
la val d10 laco

/********************************************/
/*            DATASET CLEANUP               */
/********************************************/

/* Drop all duplicates */
drop if dupid=="true"
drop dupid dupscore fraudscore

/* Drop non-consent */
drop if q1==2

/* Cleanup online-offline gaming */
replace pt10=. if pt9==1

/********************************************/
/*          RESPONSE QUALITY INDEX          */
/********************************************/

gen rq1=0
replace rq1=1 if b1==13

gen rq2=0
replace rq2=1 if mc1==4 & control==1
replace rq2=1 if mc1==2 & treatment==1

gen rq3=0
replace rq3=1 if mc2==3

gen rq4=0
replace rq4=1 if mc3==1

gen rq5=0
replace rq5=1 if dv14_4==7
replace rq5=0.5 if dv14_4==6 			// Half-point for an answer that is *almost* accurate.
replace rq5=0.5 if dv14_4==8            // Half-point for an answer that is *almost* accurate.
gen rqindex = ((rq1 + rq2 + rq3 + rq4 + rq5)/5)
la var rqindex "Response Quality Index" // Scale 0-1. The higher the score, the higher quality of response.

save "Bacovsky-LevelUpData_JEPS_Replication.dta", replace
